from timerange import TimeRange
from friend import Friend
from custom_list import CustomList
import helpers


def main():
    avalible_minutes = CustomList(range(1440))
    f1 = Friend('John')
    f1.add_busy_range(TimeRange(start_time='02:00', end_time='06:00'))
    f1.add_busy_range(TimeRange(start_time='08:00', end_time='10:00'))

    f2 = Friend('Mike')
    f2.add_busy_range(TimeRange(start_time='08:00', end_time='14:00'))
    f2.add_busy_range(TimeRange(start_time='18:00', end_time='23:30'))

    f3 = Friend('Mary')
    f3.add_busy_range(TimeRange(start_time='17:00', end_time='23:30'))

    for i in avalible_minutes[:]:
        for r in Friend.all_busy_minutes_range:
            if i in r:
                avalible_minutes.remove_if_exists(i)

    for tr in helpers.prettify_avalible_minutes(avalible_minutes):
        print(f'You can meet in {tr}')


if __name__ == '__main__':
    main()
